package com.wuwei.elearning.messageQueen;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

/**
 * Example usage of the message queue
 */
@Component
@Slf4j
public class MessageQueueRegister {
    
    private final MessageQueue messageQueue;
    
    @Resource
    private PPTMessageConsumer pptMessageConsumer;

    @Resource
    private WordMessageConsumer wordMessageConsumer;

    @Resource
    private VideoMessageConsumer videoMessageConsumer;
    
    @Autowired
    public MessageQueueRegister(MessageQueue messageQueue) {
        this.messageQueue = messageQueue;
    }

    @PostConstruct
    public void init() {
        // Register the document message consumer
        messageQueue.registerConsumer(pptMessageConsumer);
        messageQueue.registerConsumer(wordMessageConsumer);
        messageQueue.registerConsumer(videoMessageConsumer);
        log.info("Registered DocumentMessageConsumer for topic: {}", pptMessageConsumer.getTopic());
        log.info("Registered DocumentMessageConsumer for topic: {}", wordMessageConsumer.getTopic());
        log.info("Registered DocumentMessageConsumer for topic: {}", videoMessageConsumer.getTopic());
    }
} 